﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:mr="http://mishrareader.codeplex.com/Reader">


    <Style TargetType="{x:Type mr:WatermarkPasswordBox}">
        <Style.Resources>
            <Style x:Key="WatermarkPasswordBox" TargetType="{x:Type PasswordBox}">
                <Setter Property="OverridesDefaultStyle" Value="True"/>
                <Setter Property="MinHeight" Value="26" />
                <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                <Setter Property="CaretBrush" Value="{DynamicResource MetroTextBoxCaret}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type PasswordBox}">
                            <Grid>
                                <Rectangle x:Name="Border" Fill="Transparent" SnapsToDevicePixels="True" Stroke="{DynamicResource MetroTextBoxBorder}" StrokeThickness="1" />
                                <ScrollViewer Margin="3,4,3,2" x:Name="PART_ContentHost" />
                                
                            </Grid>
                            <ControlTemplate.Triggers>

                                <Trigger Property="IsEnabled" Value="False">
                                    <Setter TargetName="Border" Property="Opacity" Value="0.5"/>
                                </Trigger>                                
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="Border" Property="Stroke" Value="{DynamicResource MetroTextBoxBorderHover}"/>
                                </Trigger>
                                <Trigger Property="IsFocused" Value="True">
                                    <Setter TargetName="Border" Property="Stroke" Value="{DynamicResource MetroTextBoxBorderHover}"/>
                                    <Setter TargetName="Border" Property="Fill" Value="{DynamicResource MetroTextBoxBgFocus}"/>
                                </Trigger>

                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Style.Resources>
        <Setter Property="MinHeight" Value="26" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type mr:WatermarkPasswordBox}">
                    <Grid>
                        <Rectangle IsHitTestVisible="False"  x:Name="Background" Fill="{DynamicResource MetroTextBoxBg}" SnapsToDevicePixels="True" Stroke="{DynamicResource MetroTextBoxBorder}" StrokeThickness="1" />
                        <PasswordBox x:Name="PART_PasswordBox" Style="{StaticResource WatermarkPasswordBox}" />
                        <TextBlock x:Name="PART_Watermark" Text="{TemplateBinding Watermark}" 
                                       IsHitTestVisible="False" 
                                       Focusable="false" 
                                       Visibility="Collapsed" 
                                       HorizontalAlignment="Left" Margin="5,2" VerticalAlignment="Center" Style="{DynamicResource WaterMarkerTextBlock}" />
                        <Rectangle Visibility="Collapsed" IsHitTestVisible="False"  x:Name="Border" SnapsToDevicePixels="True" Stroke="{DynamicResource MetroTextBoxErrorBorder}" StrokeThickness="1" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Border" Property="Opacity" Value="0.5"/>
                        </Trigger>
                        <Trigger Property="Validation.HasError" Value="True">
                            <Setter Property="ToolTip" Value="{Binding (Validation.Errors)[0].ErrorContent, RelativeSource={RelativeSource Self}}" />
                            <Setter TargetName="Border" Property="Visibility" Value="Visible" />
                            <Setter TargetName="Background" Property="Fill" Value="{DynamicResource MetroTextBoxErrorBg}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Validation.ErrorTemplate">
            <Setter.Value>
                <ControlTemplate>
                    <AdornedElementPlaceholder />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    
</ResourceDictionary>